package com.blocks.model;

import com.jme3.math.Vector3f;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.shape.Box;
import com.jme3.util.BufferUtils;

public class BlockBox extends Box{
	private float x1 = 0.0f;
	private float x2 = 1.0f;
	private float y1 = 0.0f;
	private float y2 = 1.0f;;

    public BlockBox(Vector3f center, float x, float y, float z, float sectionsX, float sectionsY, float row, float column) {
    	
        this.x1 = (1/sectionsX)*column;
        this.y1 = (1/sectionsY)*row;
        this.x2 = (1/sectionsX)*(column+1);
        this.y2 = (1/sectionsY)*(row+1);
        
        updateGeometry(center, x, y, z);
	}

	@Override
    protected void duUpdateGeometryTextures() {
	    float[] SIZED_GEOMETRY_TEXTURE_DATA = {
	        	x2, y1, x1, y1, x1, y2, x2, y2, // back
	        	x2, y1, x1, y1, x1, y2, x2, y2, // right
	        	x2, y1, x1, y1, x1, y2, x2, y2, // front
	        	x2, y1, x1, y1, x1, y2, x2, y2, // left
	        	x2, y1, x1, y1, x1, y2, x2, y2, // top
	        	x2, y1, x1, y1, x1, y2, x2, y2  // bottom
	        };
        if (getBuffer(Type.TexCoord) == null){
            setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(SIZED_GEOMETRY_TEXTURE_DATA));           
        }
    }
	
	public void setX1(float x1) {
		this.x1 = x1;
	}
	public void setX2(float x2) {
		this.x2 = x2;
	}
	public void setY1(float y1) {
		this.y1 = y1;
	}
	public void setY2(float y2) {
		this.y2 = y2;
	}
    
    

}
